﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DBBase;

namespace Business
{
    public partial class NormalOperation : Form
    {
        public MainForm m_mainform;
        public NormalOperation()
        {
            InitializeComponent();
        }

        private void but_save_Click(object sender, EventArgs e)
        {
            getallTreeNode(treeView1.Nodes);
        }
       
        private void getallTreeNode(TreeNodeCollection nodes)
        {
            foreach (TreeNode td in nodes)
            {
                //  td.Text 读取该node;
               var sname="";
               sname = td.Text;
                var feichanggui="否";
                if(td.Checked)
                {
                    feichanggui="是";
                }

                updatedate(sname, feichanggui);
            }
        }
        public void updatedate(string name, string sfeichanggui)
        {

            Query objquery = new Query();
            string ssql = "";
            ssql = string.Format(@"Select count(*) From NormalOperation where NO_name='{0}'", name);
            if (objquery.ExecuteS(ssql))
            {

                ssql = string.Format(@"update  NormalOperation set NO_feichanggui='{0}' where NO_name='{1}'", sfeichanggui, name); ;
                
                
            }
            else
            {
                ssql = string.Format(@"insert into NormalOperation (NO_name,NO_feichanggui) values ('{0}','{1}')", name, sfeichanggui);
            }

            ssql = string.Format(@"update  NormalOperation set NO_feichanggui='{0}' where NO_name='{1}'", "业务退办", "1"); 
            objquery.ExecuteS(ssql);
        }
    }
}
